home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 8
/
Eagles_Nest_Mac_Collection_Disc_8.TOAST
/
Developer Tools⁄Additions
/
PSErrorHandl
/
PEH
/
DEBUG.PS
< prev
next >
Wrap
Text File
|
1989-10-11
|
24KB
|
1,007 lines
%!
%% Advanced PostScript Error Handler
%% Copyright (C) 1989 by Systems of Merritt, Inc.
%% All Rights Reserved
%% Created by Frank Merritt Braswell
%%
%% Systems of Merritt, Inc.
%% 2551 Old Dobbin Drive East
%% Mobile, AL 36695
%% (205) 660-1240
%% Revision dates 8/10/89-9/27/89
% Purpose - To print diagnostic information during error conditions
% Usage - Send program to a PostScript printer via any available
% communication channel on Mac or PC.
% Diagnostic messages may be viewed by watching the
% reverse channel.
% Documentation - Accompanying hardcopy documentation describes
% program usage and interpretation of the PostScript execution
% stack for advanced debugging.
% Output - Error information can be viewed on the reverse channel.
% Hardcopy output can also be requested.
% This program was designed to run on Adobe PostScript printers and
% may not run on clone printers. If you have any questions or
% problems, please call Systems of Merritt, Inc.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OPTION SETTINGS
% Below are 4 boolean variables which control program options. To
% select or disable an option, the user must change the true or false
% settings accordingly. Any ascii text editor can be used to modify and
% save the file.
%
% The variables may be changed independent of each other.
%
% DESCRIPTIONS
%
% /_fmb_printout
% This variable determines if error information is printed when
% an error occurs. The first page printed represents any marks
% the user has placed on the page prior to the error. The error
% handler simply issues a "showpage" and does not write on the user's
% page. Following are one or more pages (usually one page)
% with error information.
%
% /_fmb_printout VALUES
% true : showpage issues and error information printed
% false: nothing printed
%
% /_fmb_switchan
% When the user is operating in serial batch mode on either the
% 9 pin or 25 pin channel the error handler switches to the alternate
% I/O channel to enter the executive mode. This has no effect if the
% communications mode is AppleTalk or the alternate channel is
% turned off.
%
% /_fmb_switchan VALUES
% true : switch channels when error occurs
% false: do not switch channels
%
% /_fmb_printallstack
% This options allows an abbreviated copy of the execution
% stack to be printed. The execution stack contains several
% Adobe system procedures which do not concern most users.
% The user's program appears at the top ot the execution stack and
% is printed in either case.
%
% /_fmb_printallstack VALUES
% true : print entire execution stack including Adobe procs
% false: print abbreviated execution stack
%
% /_fmb_gotoexecutive
% This determines whether the executive or interactive
% mode is entered after an error. Once in the executive mode,
% the user can request a hardcopy printout of the error information
% or examine variables used by the aborted program.
%
% /_fmb_gotoexecutive VALUES
% true : enter executive mode upon error
% false: do not enter executive
%
% RESTRICTIONS
%
% In general, when running AppleTalk, it is not possible to use the _fmb_gotoexecutive
% option without possibly affecting the entire network. Unless you know what you
% are doing, "_fmb_gotoexecutive" should be set to false when using AppleTalk.
%
% LOOK BELOW FOR OPTION VARIABLES CODE BLOCK
% The option variables had to be placed after the exitserver code. They
% are clearly marked about 30 lines down from here.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0000 % THIS IS YOUR PASSWORD!!!
% MAKE SURE IT IS CORRECT OR PROGRAM WILL
% NOT LOAD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dup statusdict begin checkpassword end
{
serverdict begin exitserver
}
{
=print ( ) =print (: This is not your system password!) =
(Advanced PostScript Error Handler cannot be downloaded.) =
(Please supply Advanced PostScript Error Handler \
program with correct password.) = flush
/Courier findfont 10 scalefont setfont
30 215 moveto
(***** SYSTEMS OF MERRITT, INC. ADVANCED POSTSCRIPT ERROR HANDLER *****)
show
30 200 moveto
(Incorrect Password - Advanced PostScript Error Handler not loaded.) show
30 185 moveto
(Make sure password in Advanced PostScript Error Handler \
matches your printer password.) show
systemdict /showpage get exec
stop
} ifelse
vmstatus
pop /_fmb_vm exch def pop
/_fmb_=string 128 string def
{ % catch option errors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OPTION VARIABLES
%
/_fmb_printout % paper output?
true def % default value: true
/_fmb_switchan % switch channels?
false def % default value: false
/_fmb_printallstack % print all execution stack?
false def % default value: false
/_fmb_gotoexecutive % enter executive mode after error?
false def % default value: false
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OVERRIDE VARIABLE
%
% If another error handler is taking over (usually from an
% application program) set this variable to true.
% When set to true, no other error handler can take precidence
% over the Advanced PostScript Error Handler.
%
/_fmb_override % override another error handler
false def % default value: false
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
} stopped
{
(Option error!!!!!!!!!!!!!) = flush
/Courier findfont 10 scalefont setfont
30 215 moveto
(***** SYSTEMS OF MERRITT, INC. ADVANCED POSTSCRIPT ERROR HANDLER *****)
show
30 200 moveto
(Option Error - Advanced PostScript Error Handler not loaded.) show
30 185 moveto
(Check Advanced PostScript Error Handler option variables \
for correct syntax.) show
30 170 moveto
(%%[ Error: ) show
$error /errorname get _fmb_=string cvs show
(; OffendingCommand: ) show
$error /command get _fmb_=string cvs show
( ]%%) show
systemdict /showpage get exec
stop
} if
userdict
/_fmb_handleerror
{
$error begin
newerror
{
/newerror false def
vmstatus
_fmb_d begin
/vmtotal exch def
/vmused exch def
/savelev exch def
end % _fmb_d
(%%[ Error: ) print
errorname
{
dup type
/stringtype
ne
{
_fmb_=string cvs
} if
print
}
exec
(; OffendingCommand: ) print
/command load
{
dup type
/stringtype
ne
{
_fmb_=string cvs
} if
print
}
exec
( ]%%)
{
{
dup type
/stringtype
ne
{
_fmb_=string cvs
} if
print
}
exec
(\n) print
}
exec
flush
errorname /VMerror ne
{
_fmb_d /my_usertime usertime put
_fmb_d /_fmb_jl1 ( ) put
_fmb_d /_fmb_jl2 ( ) put
execdict /execdepth get 0 eq
{ % if not in executive enter it
_fmb_d begin
_fmb_==dict begin
serverdict begin
stdin status
errorname /timeout eq
stdin bytesavailable 0 eq
and not
and
{ % need to dump input
stdin _fmb_junkline1 readstring
{ % EOF not encountered
{ % dump remainder
stdin _fmb_junkline2 readstring
{ % not EOF
pop
}
{ % EOF
pop exit
} ifelse
} loop
(\n) search
{ % \n found
/_fmb_jl1 exch store
pop
(\n) search
{ % \n found
/_fmb_jl2 exch store
pop pop
}
{ % \n not found
/_fmb_jl2 exch store
} ifelse
}
{ % \n not found
dup length rmargin
le
{ % string le rmargin
/_fmb_jl1 exch store
/_fmb_jl2 ( ) store
}
{ % string gt rmargin
/_fmb_jltemp exch store
_fmb_jltemp 0 rmargin 1 sub get
/_fmb_jl1 exch store
_fmb_jltemp rmargin _fmb_jltemp length rmargin sub get
/fmb_jl2 exch store
} ifelse
} ifelse
}
{ % EOF found
(\n) search
{ % \n found
/_fmb_jl1 exch store
pop
(\n) search
{ % \n found
/_fmb_jl2 exch store
pop pop
}
{ % \n not found
dup length 0 gt
{ % string for jl2
/_fmb_jl2 exch store
}
{ % null string
pop
/_fmb_jl2 _fmb_EOF store
} ifelse
} ifelse
}
{ % \n not found
dup length rmargin
le
{ % string le rmargin
dup length 0 eq
{
/_fmb_jl1 _fmb_EOF store
/_fmb_jl2 ( ) store
}
{
/_fmb_jl1 exch store
/_fmb_jl2 _fmb_EOF store
} ifelse
}
{ % string gt rmargin
/_fmb_jltemp exch store
_fmb_jltemp 0 rmargin 1 sub get
/_fmb_jl1 exch store
_fmb_jltemp rmargin _fmb_jltemp length rmargin sub get
/fmb_jl2 exch store
} ifelse
} ifelse
} ifelse
}
{ % already at EOF
/_fmb_jl1 _fmb_EOF store
/_fmb_jl2 ( ) store
} ifelse
end % serverdict
end % _fmb_==dict
(%%[ EOF Encountered ]%%) = flush
end % _fmb_d
statusdict /waittimeout 5 put
_fmb_printout
{ % print error information on paper
_fmb_err_printout
} if
_fmb_err
_fmb_gotoexecutive
{ % enter executive mode
% first check to see if channel switching enabled
serverdict /altname known
statusdict /setstdio known and
{ % protect _fmb_switchan from nonexistant alt channel
_fmb_switchan
serverdict /altname get null ne
and
{ % switch to altio if _fmb_switchan true
serverdict begin
statusdict begin
altin altout setstdio
end % statusdict
end % serverdict
} if
} if
statusdict /jobname (Advanced PostScript Error Handler) put
userdict /prompt
{
(Advanced PostScript Error Handler) print execdepth
{
(>) print
} repeat flush
}
put
cleardictstack clear
executive
} if
} if
}
{ % if VMerror
statusdict /setblink known
{
statusdict begin
usertime 7000 add
{
5 setblink
dup usertime sub
0 lt
{ exit
} if
} loop
end % statusdict
} if
} ifelse
} if % newerror
end% $error
} bind put % place _fmb_handleerror in userdict
errordict /handleerror userdict /_fmb_handleerror get put
% stack builder
/_fmb_stacks
{
$error /ostack get null ne
{
cleardictstack
clear
2 1 $error /dstack get
length 1 sub
{
$error /dstack get
exch get begin
} for
$error /ostack get
{} forall
} if
} def
systemdict /.error known
{
userdict begin
/_fmb_.error { _fmb_override
{
errordict /handleerror userdict /_fmb_handleerror get put
userdict /handleerror {errordict /handleerror get exec} put
} if
/.error exec
}
dup dup length 2 sub systemdict /.error get put
bind def
end % userdict
errordict begin
/typecheck
{/typecheck /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/invalidaccess
{/invalidaccess /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/nocurrentpoint
{/nocurrentpoint /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/unregistered
{/unregistered /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/invalidfileaccess
{/invalidfileaccess /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/invalidfont
{/invalidfont /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/ioerror
{/ioerror /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/stackoverflow
{/stackoverflow /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/timeout
{/timeout /timeout /_fmb_.error exec} dup 2 userdict /_fmb_.error get put def
/rangecheck
{/rangecheck /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/undefinedresult
{/undefinedresult /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/stackunderflow
{/stackunderflow /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/syntaxerror
{/syntaxerror /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/undefinedfilename
{/undefinedfilename /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/undefined
{/undefined /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/limitcheck
{/limitcheck /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/unmatchedmark
{/unmatchedmark /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/execstackoverflow
{/execstackoverflow /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/VMerror
{/VMerror /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/invalidexit
{/invalidexit /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/dictstackoverflow
{/dictstackoverflow /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/invalidrestore
{/invalidrestore /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/dictfull
{/dictfull /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
/dictstackunderflow
{/dictstackunderflow /_fmb_.error exec} dup 1 userdict /_fmb_.error get put def
end % errordict
} if
% dict getter
/_fmb_d 60 dict def
_fmb_d begin
% define entries as
% dictionary string-name
% where the dictionary is the key and string-name is value
/_fmb_version 1.0008 def
/systemdict load (-systemdict- ) def
/userdict load (-userdict- ) def
/$error load (-$error- ) def
/statusdict load (-statusdict- ) def
/errordict load (-errordict- ) def
/FontDirectory load (-FontDirectory- ) def
/serverdict load (-serverdict- ) def
% define some strings
/_fmb_junkline1 60 string def
/_fmb_junkline2 60 string def
/_fmb_jl1 _fmb_junkline1 def
/_fmb_jl2 _fmb_junkline2 def
/_fmb_jltemp _fmb_junkline2 def
/_fmb_EOF (---End of File---) def
end % _fmb_d
% _fmb_==dict is used to show procedures
% on the page just like ==dict is used
% to display objects on the reverse
% channel
/_fmb_==dict 50 dict def
_fmb_==dict begin % open _fmb_==dict
/my== % my== is similar to == except that
% it accesses the my== dictionary
{
_fmb_==dict begin
/cp 0 def typeprint nl
end % _fmb_==dict
} bind def
/pageboundries
{
gsave 0 0 moveto clippath pathbbox grestore
/ury exch def /urx exch def
/lly exch def /llx exch def
/rm urx def /bm lly 12 add def
/tm ury 12 sub def /lm llx 12 add def
/line tm def
} bind def
/_fmb_banner
{
nl
(Advanced PostScript Error Handler Version )
=print _fmb_d /_fmb_version get my==
(Copyright (C) 1989 by Systems of Merritt, Inc.) =print nl
statusdict begin
(Product: ) =print product =print (, Version: ) =print
version =print (, Revision: ) =print revision my==
end % statusdict
_fmb_d begin
_fmb_d /vmtotal known
{
(Total VM: ) =print vmtotal =print
(, VM Used: ) =print vmused =print
(, VM Left: ) =print vmtotal vmused sub my==
(Current Save Level: ) =print savelev
serverdict /stdname known
{
=print
(, Interface: ) =print
serverdict /stdname get
} if
=
} if
(Usertime: ) =print
_fmb_d /my_usertime known
{
_fmb_d /my_usertime get
}
{
usertime
} ifelse
my== nl
end % _fmb_d
} def
/courier /Courier findfont 10 scalefont def
/outfs serverdict /stdout get def
/print { outfs exch writestring } def
/flush { outfs flushfile } def
/NL (\n) def
/nl_rchan {(\n) =print} def
/nl_printout
{
/line line 10 sub store
line bm le
{
systemdict /showpage get exec
/line tm def
} if
lm line moveto
} def
/=print_rchan
{
dup type /stringtype ne
{ _fmb_=string cvs
} if
print
} def
/=_rchan
{
/=print_rchan load exec nl_rchan
} def
/=print_printout
{
dup type /stringtype ne
{
_fmb_=string cvs
} if
show
} bind def
/=_printout
{
/=print_printout load exec nl_printout
} bind def
/_fmb_ostack 0 def
/cp 0 def
/len 0 def
/rmargin 60 def % define variables and procedures
% contained in _fmb_==dict
/typeprint % typeprint
{
dup type exec
} bind def
/tprint_rchan
{
dup length cp add rmargin gt
{
NL print /cp 0 def
} if
dup length cp add /cp exch def print
} bind def
/tprint_printout % tprint
{ % this procedure deviates from the
dup length cp add rmargin gt % adobe ==dict with slight changes
% which show information on the
% page instead of on the reverse
% channel when == is invoked
{
nl /cp 0 def
} if
dup length cp add /cp exch def show
} bind def
/cvsprint % cvsprint
{
_fmb_=string cvs tprint ( ) tprint
} bind def % cvsprint ends here
/savetype % savetype
{
pop (-savelevel- ) tprint
} bind def
/nulltype % nulltype
{
pop (-null- ) tprint
} bind def
/operatortype % operatortype
{
(--) tprint _fmb_=string cvs tprint
(--) tprint
} bind def
/stringtype % stringtype
{
dup rcheck
{
(\() tprint tprint (\)) tprint
}
{
pop (-string- ) tprint
} ifelse
} bind def
/arraytype % arraytype
{
dup rcheck
{
dup xcheck
{
({) tprint
{
typeprint
} forall
(}) tprint
}
{
([) tprint
{
typeprint
} forall
(]) tprint
} ifelse
}
{
pop (-array- ) tprint
} ifelse
} bind def
/fonttype % fonttype
{
pop (-fontid- ) tprint
} bind def
/packedarraytype % packedarraytype
{
dup rcheck
{
dup xcheck
{
({) tprint
{
typeprint
} forall
(}) tprint
}
{
([) tprint
{
typeprint
} forall
(]) tprint
} ifelse
}
{
pop (-packedarray- ) tprint
} ifelse
} bind def
/marktype % marktype
{
pop (-mark- ) tprint
} bind def
/integertype % integertype
{
cvsprint
} bind def
/dicttype % dicttype
{
dup _fmb_d exch known
{
_fmb_d exch get
}
{
pop (-dictionary- )
} ifelse
tprint
} bind def
/filetype % filetype
{
dup _fmb_d exch known
{
_fmb_d exch get
}
{
pop (-filestream- )
} ifelse
tprint
} bind def
/nametype % nametype
{
dup xcheck not
{
(/) tprint
} if
cvsprint
} bind def
/booleantype % booleantype
{
cvsprint
} bind def
/realtype % realtype
{
cvsprint
} bind def
end % _fmb_==dict
/_fmb_err_printout
{
userdict /#copies 1 put
systemdict /showpage get exec % display any marks already on the page
% then print error status page(s)
_fmb_==dict begin
courier setfont
/nl /nl_printout load def
/tprint /tprint_printout load def
/= /=_printout load def
/=print /=print_printout load def
pageboundries
/rmargin urx llx sub 10 div def
end % _fmb_==dict
{
_fmb_err_out
} stopped pop
systemdict /showpage get exec
} def
/_fmb_err
{
_fmb_==dict begin
/nl /nl_rchan load def
/tprint /tprint_rchan load def
/= /=_rchan load def
/=print /=print_rchan load def
/rmargin 60 def
end % _fmb_==dict
_fmb_==dict /outfs serverdict /stdout get put
{
_fmb_err_out
} stopped pop
% send error information to reverse channel in all cases
serverdict /altname known
{ % try to send info to alternate channel also
serverdict /altname get null ne
serverdict /altout get type /filetype eq and
{
_fmb_==dict /outfs serverdict /altout get put
{
_fmb_err_out
} stopped pop
_fmb_==dict /outfs serverdict /stdout get put
} if
} if
} def
/_fmb_err_out
{
$error begin
_fmb_==dict begin
_fmb_banner
ostack null eq
estack null eq or
dstack null eq or
{
(No errors to report at this time.) = nl flush
end % _fmb_==dict
end % $error
stop
} if
_fmb_d begin
serverdict /altin known
{
serverdict /altin get
dup type /filetype eq
{
(-altin_filestream- ) def
}
{
pop
} ifelse
} if
serverdict /altout known
{
serverdict /altout get
dup type /filetype eq
{
(-altout_filestream- ) def
}
{
pop
} ifelse
} if
serverdict /stdin known
{
serverdict /stdin get
dup type /filetype eq
{
(-stdin_filestream- ) def
}
{
pop
} ifelse
} if
serverdict /stdout known
{
serverdict /stdout get
dup type /filetype eq
{
(-stdout_filestream- ) def
}
{
pop
} ifelse
} if
end % _fmb_d
(2 lines immediately after error line:) =
_fmb_d /_fmb_jl1 get =
_fmb_d /_fmb_jl2 get =
nl
(offending command: ) =print
/command load my==
(error name: ) =print
/errorname load my==
nl
(dict stack (starts at bottom of dict stack):) =print nl
/errorname load /dictstackoverflow eq
{
ostack ostack length 1 sub get
}
{
dstack
} ifelse
/cp 0 store ([) tprint
{
typeprint
} forall
(]) tprint nl nl
(operand stack (starts at bottom of operand stack):) =print nl
/len ostack length 1 sub store
/errorname load /execstackoverflow eq
/errorname load /dictstackoverflow eq or
{
/len ostack length 2 sub store
} if
/errorname load /stackoverflow eq
{
ostack ostack length 1 sub get
dup length 1 sub
/len exch store
}
{
ostack
} ifelse
/_fmb_ostack exch store
/cp 0 store ([) tprint
0 1 len
{
_fmb_ostack exch get
typeprint
} for
(]) tprint nl nl
(BOTTOM of execution stack:) =print nl nl
_fmb_d begin
/printrest _fmb_printallstack def
_fmb_printallstack not
{
{ System Software}
my==
} if
/errorname load /execstackoverflow eq
{
ostack ostack length 1 sub get
}
{
estack
} ifelse
{ % forall
dup type /filetype eq
{
/printrest true def
} if
printrest
{
my==
}
{
pop
} ifelse
} forall
end % _fmb_d
nl
(TOP of execution stack) =print nl nl flush
end % _fmb_==dict
end % $error
} def
(Advanced PostScript Error Handler\n) print flush
(Copyright (C) 1989 by Systems of Merritt, Inc.\n) print flush
(Finished Loading\n) print flush
vmstatus pop
_fmb_vm sub (VM used: ) print _fmb_=string cvs print flush